<!--
 * @Description: 
 * @Autor: Zhu_liangyu
 * @Date: 2020-05-31 11:27:23
--> 
<template>
  <a-card :bordered="false">
    <page-table
      rowKey="moduleId"
      ref="modulePageTable"
      :query-api="module_queryPageApi"
      :delete-api="module_deletesApi"
      :columns="columns"
      @addClick="addModule"
    >
      <template #customModuleName="{record}">
        <qc-link @click="showModuleForm(record)">{{record.moduleName}}</qc-link>
      </template>
    </page-table>
    <a-modal title="模块详情" :visible="visible" @cancel="hideModuleForm" :footer="null">
      <module-form v-if="visible" :module-id="currentModuleId"></module-form>
    </a-modal>
  </a-card>
</template>
<script>
import { module_queryPageApi, module_deletesApi } from "@/api/org/module";
import ModuleForm from "@/views/org/module/form";
import { moduleTableColumns } from "@/profile/org/module";
export default {
  components: { ModuleForm },
  data() {
    return {
      columns: moduleTableColumns,
      module_queryPageApi,
      module_deletesApi,
      visible: false,
      currentModuleId: null
    };
  },
  methods: {
    reloadTable() {
      this.$refs.modulePageTable.reload();
    },
    showModuleForm(record) {
      this.currentModuleId = record.moduleId;
      this.visible = true;
    },
    addModule() {
      this.currentModuleId = null;
      this.visible = true;
    },
    hideModuleForm() {
      this.currentModuleId = null;
      this.visible = false;
      this.reloadTable();
    }
  }
};
</script>
